import { _decorator, AudioSource, Component, instantiate, UITransform } from 'cc';
import { G_VIEW_SIZE } from '../../Boost';
import { ResManager } from '../../fw/res/ResManager';
const { ccclass, property } = _decorator;

@ccclass('LoginEntry')
export class LoginEntry extends Component {
    start() {
        this.scheduleOnce(() => {
            ResManager.getInstance().loadPrefab("Match3BN", "Match3UI", prefab => {
                let match3Node = instantiate(prefab);
                this.node.addChild(match3Node);
                match3Node.getComponent(UITransform).setContentSize(G_VIEW_SIZE.clone());
            });
            // 加载背景音乐后播放
            ResManager.getInstance().loadAudioClip("Match3BN", "Audio/bgm", audioClip => {
                let audioSource = this.node.addComponent(AudioSource);
                audioSource.clip = audioClip;
                audioSource.loop = true;
                audioSource.play();
            })
        }, 1)
    }
}
